<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        list-style: none;
      }
      .news {
        display: flex;
        height: 120px;
        width: 600px;
        margin: 0 auto;
        padding: 20px 0;
        cursor: pointer;
      }
      .news .left {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding-right: 10px;
      }
      .news .left .title {
        font-size: 20px;
      }
      .news .left .info {
        color: #999999;
      }
      .news .left .info span {
        margin-right: 20px;
      }
      .news .right {
        width: 160px;
        height: 120px;
      }
      .news .right img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <ul>
        <li v-for="v of list" :key="v.id" class="news">
          <div class="left">
            <div class="title">{{ v.title }}</div>
            <div class="info">
              <span>{{ v.source }}</span>
              <span>{{ v.time }}</span>
            </div>
          </div>
          <div class="right">
            <img :src="v.img" alt="" />
          </div>
        </li>
      </ul>
    </div>
    <script src="./vue.js"></script>
    <script src="./axios.js"></script>
    <script>
      // 接口地址：http://hmajax.itheima.net/api/news
      // 请求方式：get
      const app = new Vue({
        el: '#app',
        data: {
          list: [],
        },
        async created() {
          const res = await axios({
            method: 'get',
            url: 'http://hmajax.itheima.net/api/news',
          });
          // console.log(res, 'res');

          this.list = res.data.data;
        },
      });
    </script>
  </body>
</html>
